/*
 * Daniel R Padilla
 *
 * Copyright (c) 2007, Daniel R Padilla
 *
 * This copyrighted material is made available to anyone wishing to use, modify,
 * copy, or redistribute it subject to the terms and conditions of the GNU
 * Lesser General Public License, as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License
 * for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this distribution; if not, write to:
 * Free Software Foundation, Inc.
 * 51 Franklin Street, Fifth Floor
 * Boston, MA  02110-1301  USA
 */
package org.databasefacade.table.system;

import org.databasefacade.DatabaseHelper;
import org.databasefacade.table.Table;
import org.databasefacade.table.column.Column;
import org.databasefacade.table.column.datatype.StringDataType;
import org.databasefacade.translator.Translator;




/**
 * All tables require that they have a primary key. This will 
 * protect from bad design in the database but it will also 
 * create an issue in which poorly designed databases will
 * not be able to use this framework.
 * 
 * @author Daniel
 *
 */
public class DbfTableRegistryTable extends Table { 
    public final static String DB_TABLE_NAME = "DBF_TABLE_REGISTRY";
    public final static String DB_TABLE_PRIMARY_KEY = DB_TABLE_NAME + "_KEY";
    public final static String DATABASE_TABLE_NAME = "DATABASE_TABLE_NAME";
    public final static String PRIMARY_KEY_FIELD = "PRIMARY_KEY_FIELD";
	
    public DbfTableRegistryTable(DatabaseHelper helper) {
        super(helper, DB_TABLE_NAME);
        setIsConfigTable(true);
        Translator translator = helper.getTranslator();
        
        Column col = new Column(this, DATABASE_TABLE_NAME, new StringDataType(translator, 128));
        addColumn(col);
        
        col = new Column(this, DATABASE_TABLE_NAME, new StringDataType(translator, 128));
        addColumn(col);
        
        Column cr = getColumn(DATABASE_TABLE_NAME);
        cr.getDatabaseMetaData().setIsUniqueField(true);
        cr.getDatabaseMetaData().setIsRequired(true);
    }
}
